using Microsoft.AspNetCore.Mvc;
using zhwy.saas.api.Entity.Sys;
using zhwy.saas.api.Models;
using zhwy.saas.api.Services.Sinterface.Sys;

namespace zhwy.saas.api.Controllers.V1.Sys
{
    /// <summary>
    /// 角色权限关联管理
    /// </summary>
    [ApiVersion("1.0")]
    public class SysRolePermissionController : BaseController<Roles_permissionsEntity>
    {
        private readonly ISysRolePermissionService _sysRolePermissionService;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="sysRolePermissionService">角色权限关联服务</param>
        public SysRolePermissionController(ISysRolePermissionService sysRolePermissionService)
            : base(sysRolePermissionService)
        {
            _sysRolePermissionService = sysRolePermissionService;
        }

        ///// <summary>
        ///// 分配角色权限
        ///// </summary>
        ///// <param name="roleId">角色ID</param>
        ///// <param name="permissionIds">权限ID列表</param>
        ///// <returns>分配结果</returns>
        ///// <response code="200">权限分配成功</response>
        ///// <response code="400">权限分配失败</response>
        //[HttpPost("role/{roleId}/permissions")]
        //[ProducesResponseType(typeof(ApiResponse<bool>), 200)]
        //[ProducesResponseType(typeof(ApiResponse<bool>), 400)]
        //public async Task<ActionResult<ApiResponse<bool>>> AssignPermissions(int roleId, [FromBody] List<int> permissionIds)
        //{
        //    var result = await _sysRolePermissionService.AssignPermissionsAsync(roleId, permissionIds);
        //    return result
        //        ? ApiResponse<bool>.Ok(true, "权限分配成功")
        //        : ApiResponse<bool>.Error("权限分配失败");
        //}

        ///// <summary>
        ///// 移除角色权限
        ///// </summary>
        ///// <param name="roleId">角色ID</param>
        ///// <returns>移除结果</returns>
        ///// <response code="200">权限移除成功</response>
        ///// <response code="400">权限移除失败</response>
        //[HttpDelete("role/{roleId}/permissions")]
        //[ProducesResponseType(typeof(ApiResponse<bool>), 200)]
        //[ProducesResponseType(typeof(ApiResponse<bool>), 400)]
        //public async Task<ActionResult<ApiResponse<bool>>> RemoveRolePermissions(int roleId)
        //{
        //    var result = await _sysRolePermissionService.RemoveRolePermissionsAsync(roleId);
        //    return result
        //        ? ApiResponse<bool>.Ok(true, "权限移除成功")
        //        : ApiResponse<bool>.Error("权限移除失败");
        //}

        ///// <summary>
        ///// 获取角色权限ID列表
        ///// </summary>
        ///// <param name="roleId">角色ID</param>
        ///// <returns>权限ID列表</returns>
        ///// <response code="200">成功获取权限ID列表</response>
        //[HttpGet("role/{roleId}/permissions")]
        //[ProducesResponseType(typeof(ApiResponse<List<int>>), 200)]
        //public async Task<ActionResult<ApiResponse<List<int>>>> GetRolePermissionIds(int roleId)
        //{
        //    var permissionIds = await _sysRolePermissionService.GetPermissionIdsByRoleIdAsync(roleId);
        //    return ApiResponse<List<int>>.Ok(permissionIds);
        //}

        ///// <summary>
        ///// 检查角色权限
        ///// </summary>
        ///// <param name="roleId">角色ID</param>
        ///// <param name="permissionId">权限ID</param>
        ///// <returns>是否拥有权限</returns>
        ///// <response code="200">成功检查权限</response>
        //[HttpGet("role/{roleId}/permission/{permissionId}")]
        //[ProducesResponseType(typeof(ApiResponse<bool>), 200)]
        //public async Task<ActionResult<ApiResponse<bool>>> CheckPermission(int roleId, int permissionId)
        //{
        //    var hasPermission = await _sysRolePermissionService.HasPermissionAsync(roleId, permissionId);
        //    return ApiResponse<bool>.Ok(hasPermission);
        //}
    }
}